/*
 * Copyright (c) 2015 qunar. All Rights Reserved.
 */
package com.guoyu.project.web.admin.interceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.guoyu.project.common.constant.Constants;
import com.guoyu.project.model.Manager;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;

/**
 * @author: libo Date: 15-6-7 Time: 下午8:00
 */
public class LoginInterceptor extends HandlerInterceptorAdapter {

    /**
     * This implementation always returns {@code true}.
     */
    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler)
            throws Exception {
        Manager manager = (Manager) request.getSession().getAttribute(Constants.MANAGER_SERSSION);
        if (null == manager) {
            response.sendRedirect("/admin/login.htm");
        }
        return true;
    }

}
